; (function () {
    return
    /**
   * @param {number[]} nums
   * @return {void} Do not return anything, modify nums in-place instead.
   */
    var moveZeroes = function (nums) {
        let num = 0
        for (let index = 0; index < nums.length; index++) {
            const element = nums[index];
            if (element == 0) {
                num++
            } else {
                if (num != 0) {
                    nums.splice(index, 1)
                    nums.splice(index - num, 0, element)
                }
            }

        }
        return nums
    };
})();
// 官方答案
; (function () {
    // return
    /**
 * @param {number[]} nums
 * @return {void} Do not return anything, modify nums in-place instead.
 */
    var moveZeroes = function (nums) {
        let i = 0;

        for (let j = 0; j < nums.length; j++) {
            if (nums[j] !== 0) {
                nums[i++] = nums[j];
                if(j >= i) nums[j] = 0
            }
        }
        console.log(i);
        // for (let j = i; j < nums.length; j++) {
        //     nums[j] = 0;
        // }
        return nums
    };
    console.log(moveZeroes([0,1,0,2,3,4]))
})();


